home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 9 / The PC-SIG Library on CD ROM - Ninth Edition.iso / 1501_600 / DISK1533 / DISK1533.ZIP / ENLARGE.C < prev    next >
C/C++ Source or Header  |  1989-05-09  |  6KB  |  116 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3.  
  4. #define FALSE    0
  5. #define TRUE    1
  6.  
  7. #define CHARSET 56    /* characters to print */
  8. #define ROWSIZE 10    /* Rows per character  */
  9. #define COLSIZE 9    /* Columns per character */
  10. #define MAXMSG    8    /* Max bytes for a msg */
  11. #define ENDLIST 44    /* last character= 43  */
  12. #define DASHPOS 10    /* position of hyphen  */
  13.  
  14. struct    Sym {
  15.     int iPos;        /* position in table */
  16.     char cSymbol;    /* symbol to draw with */
  17.     char * pcSwitch [ROWSIZE];
  18.  
  19. } Symbols [] = {
  20.     0, '0', { "3-7", "2-8", "1289", "1289", "1289", "1289", "1289", "1289", "2-8", "3-7" },
  21.     1, '1', { "56", "4-6", "2-6", "56", "56", "56", "56", "56", "1-9", "1-9" },
  22.     2, '2', { "2-8", "1-9", "1289", "78", "67", "56", "45", "34", "2-9", "1-9" },
  23.     3, '3', { "2-8", "1-9", "1289", "78", "4-7", "4-7", "78", "1289", "1-9", "2-8" },
  24.     4, '4', { "5-9", "4-9", "3489", "2389", "1289", "1-9", "1-9", "89", "89", "89" },
  25.     5, '5', { "1-9", "1-9", "12", "12", "1-8", "2-9", "89", "1289", "1-9", "2-8" },
  26.     6, '6', { "2-8", "1-9", "1289", "12", "1-8", "1-9", "1289", "1289", "1-9", "2-8" },
  27.     7, '7', { "2-8", "1-9", "1289", "89", "89", "78", "67", "56", "45", "34" },
  28.     8, '8', { "3-7", "2-8", "1289", "1289", "2-8", "3-7", "1289", "1289", "2-8", "3-7" },
  29.     9, '9', { "2-8", "1-9", "1289", "1289", "1-9", "2-9", "89", "1289", "1-9", "2-8" },
  30.    10, '-', { "B", "B", "B", "B", "1-9", "1-9", "B", "B", "B", "B" },
  31.    11, '#', { "2378", "2378", "1-9", "1-9", "2378", "2378", "1-9", "1-9", "2378", "2378" },
  32.    12, 'A', { "4-6", "3467", "2378", "1289", "1289", "1-9", "1-9", "1289", "1289", "1289" },
  33.    13, 'B', { "1-8", "1-9", "1289", "1289", "1-8", "1-8", "1289", "1289", "1-9", "1-8" },
  34.    14, 'C', { "2-8", "1-9", "1289", "12", "12", "12", "12", "1289", "1-9", "2-8" },
  35.    15, 'D', { "1-8", "1-9", "1289", "1289", "1289", "1289", "1289", "1289", "1-9", "1-8" },
  36.    16, 'E', { "1-9", "1-9", "12", "12", "1-6", "1-6", "12", "12", "1-9", "1-9" },
  37.    17, 'F', { "1-9", "1-9", "12", "12", "1-6", "1-6", "12", "12", "12", "12" },
  38.    18, 'G', { "2-8", "1-9", "1289", "12", "12", "126-9", "126-9", "1289", "1-9", "2-8" },
  39.    19, 'H', { "1289", "1289", "1289", "1289", "1-9", "1-9", "1289", "1289", "1289", "1289" },
  40.    20, 'I', { "3-8", "3-8", "56", "56", "56", "56", "56", "56", "3-8", "3-8" },
  41.    21, 'J', { "89", "89", "89", "89", "89", "89", "89", "1289", "2-8", "3-7" },
  42.    22, 'K', { "1289", "1278", "1267", "1256", "1245", "1-5", "1256", "1267", "1278", "1289" },
  43.    23, 'L', { "12", "12", "12", "12", "12", "12", "12", "12", "1-9", "1-9" },
  44.    24, 'M', { "19", "1289", "1-37-9", "1-46-9", "124-689", "12589", "1289", "1289", "1289", "1289" },
  45.    25, 'N', { "189", "1289", "1-389", "1-489", "124589", "125689", "126-9", "127-9", "1289", "129" },
  46.    26, 'O', { "2-8", "1-9", "1289", "1289", "1289", "1289", "1289", "1289", "1-9", "2-8" },
  47.    27, 'P', { "1-8", "1-9", "1289", "1289", "1-9", "1-8", "12", "12", "12", "12" },
  48.    28, 'Q', { "2-8", "1-9", "1289", "1289", "1289", "1289", "125689", "126-9", "1-9", "2-8" },
  49.    29, 'R', { "1-8", "1-9", "1289", "1289", "1-9", "1-8", "1256", "1267", "1278", "1289" },
  50.    30, 'S', { "2-8", "1-9", "1289", "23", "34", "56", "67", "1278", "1-9", "2-8" },
  51.    31, 'T', { "2-9", "2-9", "56", "56", "56", "56", "56", "56", "56", "56" },
  52.    32, 'U', { "1289", "1289", "1289", "1289", "1289", "1289", "1289", "1289", "2-8", "3-7" },
  53.    33, 'V', { "1289", "1289", "1289", "1289", "1289", "1289", "1289", "2378", "3467", "4-6" },
  54.    34, 'W', { "1289", "1289", "1289", "1289", "12589", "124-689", "1-46-9", "1-37-9", "1289", "19" },
  55.    35, 'X', { "1289", "1289", "1289", "2378", "3-7", "4-6", "2378", "1289", "1289", "1289" },
  56.    36, 'Y', { "1289", "1289", "1289", "1289", "2378", "4-6", "45", "45", "45", "45" },
  57.    37, 'Z', { "1-9", "1-9", "78", "67", "56", "45", "34", "23", "1-9", "1-9" },
  58.    38, '.', { "B", "B", "B", "B", "B", "B", "3-7", "3-7", "3-7", "3-7" },
  59.    39, ':', { "3-7", "3-7", "3-7", "3-7", "B", "B", "3-7", "3-7", "3-7", "3-7" },
  60.    40, ';', { "3-7", "3-7", "3-7", "3-7", "B", "3-7", "3-7", "5-7", "56", "45" },
  61.    41, ',', { "B", "B", "B", "B", "B", "3-7", "3-7", "5-7", "56", "45" },
  62.    42, '%', { "2-489", "124589", "124589", "2-478", "67", "45", "236-8", "125689", "125689", "126-8" },
  63.    43, ' ', { "1-9", "1-9", "1-9", "1-9", "1-9", "1-9", "1-9", "1-9", "1-9", "1-9" }
  64. };
  65.  
  66. void enlarge(char * szMsg)
  67. {
  68.     int i, j;
  69.     char *CurChar;
  70.  
  71.     char * expand(int, int);
  72.  
  73.     for (j = 0; j < ROWSIZE; j++) {     /* rows to expand ... */
  74.     putchar ('\n');
  75.     for (CurChar = szMsg; *CurChar != '\0'; CurChar++) {
  76.         for (i = 0; i < ENDLIST; i++)
  77.         if (Symbols[i].cSymbol == *CurChar)
  78.             break;
  79.         if (i == ENDLIST)
  80.         i = DASHPOS;
  81.         fprintf(stdout, "%9s  ", expand(i, j));
  82.     }
  83.     }
  84. }
  85.  
  86. #define SPACE    ' '
  87. #define HYPHEN    '-'
  88.  
  89. static    char szOutput [COLSIZE];
  90.  
  91. char * expand (int i, int j)
  92. {
  93.     char sOutput [COLSIZE];
  94.     char *s;
  95.     char sym  = Symbols[i].cSymbol;
  96.     int indx, iCur;
  97.  
  98.     for (indx=0; indx < COLSIZE; indx++)
  99.     sOutput [indx] = SPACE;
  100.  
  101.     sOutput[COLSIZE] = '\0';    /* terminator is required */
  102.  
  103.     for ( s = Symbols[i].pcSwitch[j]; *s != '\0'; s++) {
  104.     if (isdigit (*s))
  105.         sOutput[*(s) - '0' - 1] = sym;
  106.     else if (*s == HYPHEN) {
  107.         for (iCur = *(s-1) - '0'; iCur <= *(s+1) - '0'; iCur++)
  108.             sOutput[iCur-1] = sym;
  109.         s++;
  110.         }
  111.     }        /* for block is closed -- until string is null */
  112.  
  113.     strcpy (szOutput, sOutput);
  114.     return szOutput;
  115. }
  116.